<?php
/**
 * Created by Command.
 * User: Vito
 */

declare (strict_types = 1);

namespace app\model;

class SubscribeRecord extends BaseModel
{

    public static function addRecord($res = null ,$data = null, $event = ''){
        if (!$res['errcode']) {
            $arr = [
                'data'      => json_encode($data, JSON_UNESCAPED_UNICODE),
                'result'    => 1,
                'event'     => $event,
                'content'   => json_encode($res, JSON_UNESCAPED_UNICODE),
                'user_id'   => $data['user_id'],
            ];
            // halt($arr);
            SubscribeRecord::create($arr);
        } else {
            $arr = [
                'data'      => json_encode($data, JSON_UNESCAPED_UNICODE),
                'result'    => 0,
                'event'     => $event,
                'content'   => json_encode($res, JSON_UNESCAPED_UNICODE),
                'user_id'   => $data['user_id'],
            ];
            SubscribeRecord::create($arr);
        }
    }
}
